import store from '@/store'
import { mapState } from 'vuex'
export default {
  computed: {
    ...mapState('menus', {
      $_menuBtns: state => state.menuBtns
    })
  },
  watch: {
    $route: {
      handler(route) {
        const { meta } = route
        this.$_setCurrentMenu(meta)
      },
      immediate: true
    }
  },
  methods: {
    $_setCurrentMenu(meta) {
      const { id } = meta
      store.dispatch('menus/getPageBtn', id)
    },
    $_permisson(btnCode) {
      const result = this.$_menuBtns.find(i => {
        return btnCode === i.url
      })
      if (result) return true
      return false
    }
  }
}
